import Vue from 'vue'
import axios from 'axios'
import App from './App.vue'
import './assets/base.css'
import 'windi.css'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import store from './store/store';

Vue.prototype.$http = axios
Vue.use(ElementUI);
Vue.config.productionTip = false

axios.defaults.baseURL = 'https://builder.dynamicteamsports.com/client'
axios.interceptors.request.use(
    config => {
      if (config.url.indexOf('/api/v1/auth/login') !== -1) {
        // 以multipart/form-data形式提交
        config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
      } else {
        // 以json形式提交
        config.headers['Content-Type'] = 'application/json'
      }
      // 为请求头添加token字段
      config.headers.Authorization = sessionStorage.getItem('clothesToken')
      return config
    },
    err => {
      return Promise.reject(err)
    }
)

new Vue({
  render: h => h(App),
  store
}).$mount('#app')
